package service

import (
	"ksd-social-api/commons/base/service"
	"ksd-social-api/modules/special/model"
	"ksd-social-api/modules/special/model/context"
	"ksd-social-api/modules/special/model/vo"
	"ksd-social-api/utils"
	"strconv"
)

type AdminSpecialBindService struct {
	service.BaseService
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  修改状态
 */
func (service *AdminSpecialBindService) UpdateFieldById(ctx context.SpecialUpdateContext) bool {
	return adminSpecialBindMapper.UpdateFieldById(ctx.Id.Uint64(), ctx.Field, ctx.Value, ctx.SystemId)
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  修改状态
 */
func (service *AdminSpecialBindService) SaveUpdateSpecialBind(ctx context.SpecialBindContext) *vo.SpecialBindVo {
	// 保存入库
	var specialBind model.SpecialBind
	var specialBindVo vo.SpecialBindVo
	utils.CopyProperties(&specialBind, ctx)
	parseUint, _ := strconv.ParseUint(ctx.Id, 10, 64)
	specialBind.Id = parseUint
	specialBind.SpecialId = ctx.SpecialId.Uint64()
	data := adminSpecialBindMapper.SaveUpdateSpecialBind(specialBind)
	utils.CopyProperties(&specialBindVo, data)
	return &specialBindVo
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  根据id删除
 */
func (service *AdminSpecialBindService) DelById(id uint64, systemId uint64) bool {
	return adminSpecialBindMapper.DelById(id, systemId)
}
